package com.diary.database;

import com.diary.DBUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collections;

public class Find {
    public boolean FindUser(String username) {
        int ans = 0;
        Connection connection = null;
        PreparedStatement preparedStatement = null;
        ResultSet resultSet = null;

        try {
            connection = DBUtils.getConnection();

            String sql = "select * from users where user = ?";
            preparedStatement = connection.prepareStatement(sql);

            preparedStatement.setString(1,username);

            resultSet = preparedStatement.executeQuery();
            return resultSet.next();



        } catch (SQLException e) {
            e.printStackTrace();
            return true;
        }
        finally {
            DBUtils.close(resultSet,preparedStatement, connection);
        }



    }


}
